Current Location: Home> Function Categories> date_time_set

date_time_set

DateTime::setTime alias - Set the time of the DateTime object
Name:date_time_set
Category:Date and time
Programming Language:php
One-line Description:Set the time.

Definition and usage

The date_time_set() function is used to set the time.

Example

Set time:

 <?php
$date = date_create ( "2016-09-25" ) ;
date_time_set ( $date , 12 , 36 ) ;
echo date_format ( $date , "Ymd H:i:s" ) ;
?>

Try it yourself

grammar

 date_time_set ( object , hour , minute , second ) ;
parameter describe
object Required. Specifies the DateTime object returned by date_create() .
hour Required. The hours of the specified time.
minute Required. The minutes in the specified time.
second Optional. Seconds in the specified time. The default is 0.
Similar Functions
Popular Articles